//logs.js
const util = require('../../utils/util.js')
const sliderWidth = 96; 
Page({
  data: {
    tabs: ["传感器数值", "传感器设置", "系统设置"],
    activeIndex: 0,
    sliderOffset: 0,
    sliderLeft: 0,
    logs: [{ name: "主机房温度", value: "18.5", unit:"摄氏度",status: "正常", updateTime:"2018-4-18 16:6:15"},
      { name: "主机房湿度", value: "66", status: "正常", updateTime: "2018-4-18 16:6:15" }],
    devices:[{name:"机房温度"}]
  },
  onLoad: function () {
    let that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
        that.setData({
          // logs: (wx.getStorageSync('logs') || []).map(log => {
          //   return util.formatTime(new Date(log))
          // })
        })
      }
    });
  },
  tabClick: function (e) {
    this.setData({
      sliderOffset: e.currentTarget.offsetLeft,
      activeIndex: e.currentTarget.id
    });
  }
})
